#ifndef GP_QPCR_SERVER_H
#define GP_QPCR_SERVER_H

#include <iostream>
#include <memory>
#include <string>
#include <fstream>

#include <grpcpp/grpcpp.h>

#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "defs.grpc.pb.h"
#include "defs_self.grpc.pb.h"
#include "WingDCS.grpc.pb.h"
#endif

#include <unistd.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/msg.h>
#include <string.h>

#include "/home/hcgy/Documents/esm6800h/app/common.h"
#include "/home/hcgy/Documents/esm6800h/app/msg_def.h"
#include "/home/hcgy/Documents/esm6800h/app/config/config.h"

#include "action_manage.h"

using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
using grpc::Status;
using grpc::ServerReader;
using grpc::ServerReaderWriter;
using grpc::ServerWriter;
//using GPRPC::AxisMoveParam;
using GPRPC::DCSService;
using GPRPC::PMSService;
using GPRPC::MotorMoveParam;
using GPRPC::CmdResponse;
//using GPRPC::Scheme;
using GPRPC::ReturnVal;
using GPRPC::MotorType;
using GPRPC::Void;
//using GPRPC::PosParam;
//using GPRPC::PurifyScheme;
using GPRPC::BuildPCRParam;
//using GPRPC::PCRScheme;
using GPRPC::MaintainParam;
using GPRPC::TimeSerialParam;
using GPRPC::AlarmParam;
using GPRPC::StrResponse;
using GPRPC::SpeedParam;
using GPRPC::TemperaturePara;
using GPRPC::DiffPressParam;
using GPRPC::Position;
using GPRPC::GetTempParam;
using GPRPC::PlungerPumpCtrlParam;
using GPRPC::MotorPosParam;
using GPRPC::Motor;
using GPRPC::ModuleName;
using GPRPC::ModuleMoveParam;
using GPRPC::JawGetPutParam;
using GPRPC::DjDpLiquidCtrlParam;
using GPRPC::DjDpSuckMoreSpitParam;
using GPRPC::DjDpSuckASpitParam;
using GPRPC::DpTipCtrlParam;
using GPRPC::DjPumpValveSwitchParam;
using GPRPC::DjPumpValveWorkParam;
using GPRPC::ShakeHeatParam;
using GPRPC::ShakeMagneticSingOperParam;
using GPRPC::ShakeMagneticParam;
using GPRPC::ShakeHeatMagneticParam;
using GPRPC::HeatTemp;
using GPRPC::HeatSealTestParam;
using GPRPC::SwitchCtrl;
using GPRPC::Channel;
using GPRPC::TakePictures;
using GPRPC::ChangeChannTakePictParam;
using GPRPC::ModuleType;
using GPRPC::MetalBathHeatTemp;
using GPRPC::QpcrSwitchCtrl;
using GPRPC::MetalBathAgeingTestParam;
using GPRPC::QpcrSwitchCtrl;
using GPRPC::ScancodeParam;
using GPRPC::DrawerMagLockParam;
using GPRPC::JawMoveParam;
using GPRPC::QpcrSchemeParam;
using GPRPC::MetalBathSW;
using GPRPC::GetFilmParam;
using GPRPC::ScannerSwParam;
using GPRPC::GetPutFilmParam;
using GPRPC::GetQpcrTempSWParam;
using GPRPC::BarcodeScannerPos;

using GPRPC::PosTypeParam;
using GPRPC::TransParam;


typedef enum
{
  SID_DJ_PUMP = 40,
  SID_DJ_X = 49,
  SID_DJ_Y = 50,
  SID_DJ_Z = 51,
  SID_Logistics_X = 41,
  SID_Logistics_JAW = 42,
  SID_Logistics_JawZ = 43,
  SID_Logistics_JawY = 44,
  SID_OPTICAL_FILTER = 47,
  SID_BASH_X = 48,
  SID_BASH_X1 = 55,
}enSid;



extern int g_msg_id;

//
// int sendMsgToAct(const AxisMoveParam* request,int msgType,unsigned char sidIn,
// unsigned char indexOnBoard = 0);

int sendMsgToAct(const void * request,int msgType,unsigned char sidIn);

int  sendModuleMsgToAct(int msgType,int moduleIdIn);

int  sendModuleMsgToAct(const void * request,int msgType,int moduleIdIn);
//the uint of timeOut is second

// int wait_ack_module(int timeOut,msgQueueAck * ackMsg,Response* reply,int moduleId);

// int wait_ack(int timeOut,msgQueueAck * ackMsg,Response* reply,int sid);
// // Logic and data behind the server's behavior.

// int  sendDjMsgToAct(const DjActParam* request,int msgType,int moduleIdIn);
// int  sendMsgToDjLiquidAct(const DjLiquidParam* request,unsigned int idPump);

// int procDjAddSample(const DjAddSampleParam* request,Response* reply);


#define SERVER_IP_PORT "10.3.1.28:50051"

#define REPORT_IP_PORT "10.20.2.90:50067"

int initQpcrTempReport(void);

#endif